﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using TFXK.BLL;
using TFXK.Common;
using log4net;
using TFXK.Model;

public partial class ZTMainPage : System.Web.UI.MasterPage
{
    private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
    private static readonly CategoryBLL bllCategory = new CategoryBLL();
    private static readonly NewsBLL bllNews = new NewsBLL();
    private static readonly TravelLinesBLL bllTravelLines = new TravelLinesBLL();
    int rowCount = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!IsPostBack)
            {
                BindCityLable();
                BindHelp();
                BindGNCity();
            }
        }
        catch (Exception ex)
        {
            log.Error(ex.Message);
        }
    }
    //旅游资讯
    public void BindHelp()
    {
        this.rptTravelHelp.DataSource = bllNews.GetListByShowType(15, 1, 1, out rowCount);
        rptTravelHelp.DataBind();

    }
    //导航
    public void BindGNCity()
    {
        this.rptNavGNCity.DataSource = bllCategory.GetNextNodeByCode("ztly");
        rptNavGNCity.DataBind();
    }

    //导航文字
    public void BindCityLable()
    {
        if (!string.IsNullOrEmpty(Request.QueryString["PID"] + ""))
        {
            int key = int.Parse(Request.QueryString["PID"] + "");
            if (key > 0)
            {
                try
                {
                    lblCity.Text = bllCategory.GetModel(key).title;
                }
                catch { }
            }
        }
        else
        {
            if (!string.IsNullOrEmpty(Request.QueryString["Key"] + ""))
            {
                try
                {
                    int cityid = bllTravelLines.GetModel(int.Parse(Request.QueryString["Key"] + "")).endCity.Value;
                    Category tempModel = bllCategory.GetModelList("id=" + bllCategory.GetModel(cityid).parentID)[0];
                    lblCity.Text = tempModel.title;
                }
                catch { }
            }
        }
    }

}
